home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
Tickle-4.0 (tcl)
/
src
/
tickle.h
< prev
next >
Wrap
Text File
|
1993-11-18
|
17KB
|
656 lines
/*
** This source code was written by Tim Endres
** Email: time@ice.com.
** USMail: 8840 Main Street, Whitmore Lake, MI 48189
**
** Some portions of this application utilize sources
** that are copyrighted by ICE Engineering, Inc., and
** ICE Engineering retains all rights to those sources.
**
** Neither ICE Engineering, Inc., nor Tim Endres,
** warrants this source code for any reason, and neither
** party assumes any responsbility for the use of these
** sources, libraries, or applications. The user of these
** sources and binaries assumes all responsbilities for
** any resulting consequences.
*/
#ifndef THINK_C_PRECOMPILED
#ifdef USEDUMP
#ifdef TCLAPPL
# pragma load ":obj:TickleHdrDump"
#else
# pragma load ":obj:EngineHdrDump"
#endif
#else /* ! USEDUMP */
/*
** These are the Macintosh C include files that are
** utilized by the application source code.
** They define the data structures and procedures in
** the Macintosh ROM.
*/
#include <Types.h>
#include <resources.h>
#include <quickdraw.h>
#include <fonts.h>
#include <memory.h>
#include <events.h>
#include <menus.h>
#include <files.h>
#include <fcntl.h>
#include <controls.h>
#include <windows.h>
#include <textedit.h>
#include <dialogs.h>
#include <desk.h>
#include <scrap.h>
#include <osutils.h>
#include <toolutils.h>
#include <GestaltEqu.h>
#include <packages.h>
#include <printing.h>
#include <lists.h>
#include "volumes.h"
#include <notification.h>
#include <EPPC.h>
#include <PPCToolbox.h>
#include <AppleEvents.h>
#include <Aliases.h>
#include <errors.h>
#include <stdio.h>
#include <string.h>
#include "defines.h"
#include "tcl.h"
#include "xproc.h"
#include "version.h"
/*
** The DEBUG compilation variable is used to control the
** debugging within the application. The setting
** of this variable will determine which debugging statements
** within the source code are compiled.
**
** The following DEBUG settings are utilized:
**
** 0 - No debugging at all.
** 1 - Error debugging is turned on to catch unexpected conditions.
** 5 - Temporary development code is included. Used for testing.
** 10 - Extreme debugging. Superfluous information and checking.
**
** The debug setting is established using:
**
** #define DEBUG N
**
** where N is the setting number.
**
** For the release system, DEBUG should be 0. This gives the user
** only the error checking he expects. No surprises.
**
** Normally, you will have DEBUG set to 1. This catches conditions
** you didn't expect (like not checking for a NULL from NewPtr())
** or situations you haven't coded completely yet.
**
** For serious debugging, DEBUG should be 10. All permanent debugging
** code should be placed within DEBUG > 9, all temporary debugging
** within DEBUG > 4.
**
** Thus, in your code...
**
** #if DEBUG > 0
** { Error debugging code. }
** #endif
**
** #if DEBUG > 4
** { Temporary development/testing code. }
** #endif
**
** #if DEBUG > 9
** { Permanent debugging code. Superfluous information. }
** #endif
**
*/
/*
** Set the DEBUG compilation variable.
*/
#define DEBUG 0
/*
** Set the EXPERIMENT compilation variable.
** If EXPERIMENT is defined and greater than 0,
** all experimentation code will be compiled.
*/
#define EXPERIMENT 1
/*
** If DEBUGing is on, define the Debugger() procedure in case it is used.
*/
#if DEBUG > 0
pascal void Debugger()
extern 0xA9FF;
pascal void DebugStr(aStr)
char *aStr;
extern 0xABFF;
#endif
/*
** ErrorLog declarations...
*/
#define DEFAULT_LOG_NAME "DiskTool.log"
#define LOG_ERROR 1
#define LOG_WARNING 2
#define LOG_NOTE 3
#ifndef TRUE
# define TRUE ((Boolean)1)
#endif
#ifndef FALSE
# define FALSE ((Boolean)0)
#endif
#define YIELD_ON 1
#define YIELD_OFF 0
#define SetCell(cell, row, column) { (cell).h = column; (cell).v = row; }
#define ROW(cell) (cell).v
#define noProc 0
#define MFOSEvent app4Evt /* event used by MultiFinder */
#define MFSuspendResumeMessage 1 /* high byte of suspend/resume event message */
#define MFResumeMask 1 /* bit of message field for resume vs. suspend */
#define MFMouseMovedMessage 0xFA /* high byte of mouse-moved event message */
#define keyStdOutObject 'StdO'
/*
** Several macro definitions for readability's sake.
*/
#ifndef NULL
# define NULL (char *)0
#endif
#define true 1
#define false 0
#define inFront ((WindowPtr) -1) /* Used by GetNewWindow, GetNewDialog */
#define string_equal(str1, str2) (strcmp(str1, str2) == 0)
#define stringn_equal(str1, str2, n) (strncmp(str1, str2, n) == 0)
#define NUMBER(ch) (((ch) >= '0') && ((ch) <= '9'))
#define gHiliteMode ( *( (char *) 0x0938 ) ) /* used for color highlighting */
#define CQD_COLOR_INVERT() { if (theEnviron.hasColorQD) ( (gHiliteMode) &= 0x7F ); }
/*
** Recource ID and TYPE of saved data resource.
*/
#define RSRC_DATA_TYPE (ResType)'Data'
#define RSRC_DATA_ID (short)2001
/*
** Resource ID's of application dialogs.
*/
#define info_dialog (short)2001 /* The ID of the "About..." Dialog. */
#define ask_dialog (short)2005 /* The ID of the "AskYesNo" Dialog. */
#define get_line_dialog (short)2007
#define text_conversion_dialog (short)2009
#define get_folder_dialog (short)2013
/*
** Resource ID's of application alerts.
*/
#define file_open_alert (short)1001 /* Alert - file open failure */
#define file_rename_alert (short)1002 /* Alert - file rename failure */
#define memory_error_alert (short)1006 /* Alert - Memory could not be allocated */
#define message_note_alert (short)1010 /* Alert - Note message alert */
#define message_alert_alert (short)1011 /* Alert - Alert message alert */
// #define WatchCursorOn() { SetCursor(*GetCursor(watchCursor)); }
/*
** Macros for the menu definitions.
** The following suffixes are utilized in the macro names:
** ___menu - The menu ID or number.
** ___mname - The name of the menu.
** ___mstr - The string containing the menu items.
** ___item - The corresponding number(position) of the menu items.
**
*/
#define MAX_MENU 16
/*
** The "apple" menu with "About" and the Desk Accessories.
*/
#define applemenu 1
#define apple_menu_hdl mymenus[0]
#define applemname "\001\024"
#define applemstr "\pAbout tickle...;(-;"
#define infoitem 1
/*
** The "File" menu.
*/
#define filemenu 256
#define file_menu_hdl mymenus[1]
#define new_item 1
#define open_item 2
#define save_item 3
#define save_as_item 4
#define close_window_item 5
#define page_setup_item 7
#define print_window_item 8
#define print_selection_item 9
#define open_fb_item 11
#define log_item 12
#define log_level_item 13
#define pause_op_item 15
#define cancel_op_item 16
#define run_script_item 18
#define new_folder_item 19
#define stop_icons_item 20
#define quit_item 22
/*
** The "Edit" menu.
*/
#define editmenu 257
#define edit_menu_hdl mymenus[2]
#define undoCmd 1
#define cutCmd 3
#define copyCmd 4
#define pasteCmd 5
#define clearCmd 6
#define selectAllCmd 8
#define shiftLeftCmd 10
#define shiftRightCmd 11
#define findCmd 13
#define repeatFindCmd 14
#define replaceCmd 15
#define repeatReplaceCmd 16
/*
** The "TCL" menu.
*/
#define tcl_menu 269
#define tcl_menu_hdl mymenus[12]
/*
** The "MacTools" menu.
*/
#define mtoolmenu 258
#define mtool_menu_hdl mymenus[3]
#define f_macinfo_item 1
#define f_binhex_item 3
#define f_unbinhex_item 4
#define mb_info_item 6
#define f_macbinary_item 7
#define f_unmacbinary_item 8
#define f_copyhier_item 10
#define f_hier_cmd_item 12
/*
** The "TEXT Tools" menu.
*/
#define ttoolmenu 259
#define ttool_menu_hdl mymenus[4]
#define f_split_item 1
#define f_join_item 2
#define f_convert_item 3
#define f_texttype_item 4
#define f_unixtomac_item 6
#define f_mactounix_item 7
#define f_pctomac_item 9
#define f_mactopc_item 10
/*
** The "UNIX Tools" menu.
*/
#define utoolmenu 260
#define utool_menu_hdl mymenus[5]
#define f_uuencode_item 1
#define f_uudecode_item 2
#define f_compress_item 4
#define f_decompress_item 5
/*
** The "StuffIt Tools" menu.
*/
#define stoolmenu 261
#define stool_menu_hdl mymenus[6]
#define f_stuff_file_item 1
#define f_stuff_mult_item 2
#define f_unstuff_item 3
/*
** The "Tar" menu.
*/
#define tarmenu 296
#define tar_menu_hdl mymenus[7]
#define tar_create_item 1
#define tar_extract_item 2
#define tar_list_item 3
#define tar_about_item 5
#define tar_prefs_item 6
/*
** The "Tar" submenu.
*/
#define ptarmenu 96
#define ptar_menu_hdl mymenus[8]
#define ptar_cnvrt_nl_item 1
#define ptar_old_tar_item 2
#define ptar_blk_size_item 3
#define ptar_crtr_type_item 5
/*
** The "ASD" menu.
*/
#define asdmenu 262
#define asd_menu_hdl mymenus[9]
#define asd_info_item 1
#define asd_to_mac_item 2
#define asd_to_mb_item 3
#define mac_to_as_item 5
#define mac_to_ad_item 6
#define mb_to_as_item 8
#define mb_to_ad_item 9
/*
** The "Hierarchical Commands" submenu.
*/
#define hcsubmenu 69
#define hc_submenu_hdl mymenus[10]
#define hc_ftype_item 1
#define hc_fcreator_item 2
#define hc_folderview_item 3
#define hc_file_info_item 5
#define hc_folder_info_item 6
#define hc_filefld_info_item 7
/*
** The "Hierarchical Commands" submenu.
*/
#define xcsubmenu 70
#define xc_submenu_hdl mymenus[11]
#define xc_first_item 1
typedef struct {
short case_sense;
short direction;
short wrap;
short special;
char search_str[256];
} SearchParm, *SearchParmPtr;
typedef struct {
short case_sense;
short direction;
short wrap;
short special;
short replace_all;
short search_rgn;
char search_str[256];
char replace_str[256];
} SearchReplaceParm, *SearchReplaceParmPtr;
typedef struct {
/* Common flags and info. */
short rsrc_loaded; /* True if loaded, false if defaulted. */
} RsrcData, *RsrcDataPtr;
typedef struct {
short conv_char;
short char_conv_type;
short conv_lines;
short lines_conv_type;
} TextConvSpec;
#define MAC_FILE 0
#define BINARY_FILE 1
#define BINHEX_FILE 2
#define CNV_CHARS_DEL_NON_ASCII 1
#define CNV_CHARS_STRIP_NON_ACSII 2
#define CNV_LINES_CR_TO_NL 1
#define CNV_LINES_NL_TO_CR 2
#define CNV_LINES_DEL_NLS 3
#define CNV_LINES_DEL_CRS 4
/*
** *********************************************************************
** *************************** WINODOW Stuff ***************************
** *********************************************************************
*/
#undef wDraw
#define wUpdate 1
#define wContent 2
#define wActivate 3
#define wDraw 4
#define wGrow 5
#define wClose 6
#define wKeyDown 7
#define wCut 8
#define wCopy 9
#define wPaste 10
#define wPasteFile 33
#define wUndo 11
#define wDelete 12
#define wPrint 13
#define wPrintSelection 35
#define wIdle 14
#define wZoomIn 15
#define wZoomOut 16
#define wSave 17
#define wSaveAs 18
#define wSelectAll 20
#define wFind 21
#define wRepeatFind 22
#define wReplace 23
#define wRepeatReplace 24
#define wGrowZone 27
#define feedbackWKind 1990
#define progressWKind 1991
#define WPeek ((WindowPeek) myWindow)
typedef int (*PFI)();
#define FB_MAX_LINES 128
#define FB_LINE_LENGTH 128
typedef struct {
WindowRecord super;
int active;
int line_height;
int first_line;
int total_lines;
char *buffer[FB_MAX_LINES];
Style textface[FB_MAX_LINES];
} FeedbackWindow, *FBWdwPtr;
#define FBWPtr ((FBWdwPtr) myWindow)
#define INPUT_SIZE 512
/*
** WARNING: Taken from compress.c!!!!!!!!!!
**
** a code_int must be able to hold 2**BITS values of type int, and also -1
*/
typedef long int code_int;
typedef long int count_int;
typedef unsigned char char_type;
/* End WARNING */
#ifdef ALLOCATE_GLOBALS
#define ALLOC_CLASS
#define ALLOC_INIT(def) = def
#define ALLOC_ARRAY(asize) [asize]
#else
#define ALLOC_CLASS extern
#define ALLOC_INIT(def)
#define ALLOC_ARRAY(asize) []
#endif
/*
** These are the declarations for the globals varaibles used
** by the application. They are mostly used for the
** Macintosh interface, and are generally avoided in favor
** of local variables and parameter passing. This is the
** global declaration of these variables that cause their storage
** to be allocated. (see pages 28-30, "Scope; External Variables",
** in Kernigan and Richie, "The C Programming Language").
** One and only one compiled file should declare the ALLOCATE_GLOBALS
** macro. These declarations will only be used by Application.c which will
** define ALLOCATE_GLOBALS. This is so the globals are allocated
** only once. Note: many are initialized here, as well as in the code.
** Redundancy in a sign of a programmer's paranoia.
*/
ALLOC_CLASS FILE *logfile ALLOC_INIT(NULL); /* The application exit flag. */
ALLOC_CLASS int app_done ALLOC_INIT(0); /* The application exit flag. */
ALLOC_CLASS int cancel_current_op ALLOC_INIT(0);
ALLOC_CLASS int verbose ALLOC_INIT(true); /* Flag for informative dialogs being displayed. */
ALLOC_CLASS int quiet ALLOC_INIT(false); /* Flag for informative beeps or silence */
ALLOC_CLASS int auto_feedback ALLOC_INIT(true); /* Flag to automatically popup Feedback Window */
ALLOC_CLASS int checkFBWindow ALLOC_INIT(true); /* Avoids repeating Feedback Window error message */
ALLOC_CLASS int set_log_type ALLOC_INIT(false); /* Avoids repeating log file type setting */
ALLOC_CLASS int macplus_keybd ALLOC_INIT(0); /* Avoids repeating log file type setting */
ALLOC_CLASS short app_refnum ALLOC_INIT(-1); /* The reference number for application resource fork. */
ALLOC_CLASS short app_vrefnum ALLOC_INIT(0); /* The Vol/WD reference number for application folder. */
ALLOC_CLASS Str32 app_filename ALLOC_INIT("\pTickle"); /* Application's Pascal file name */
ALLOC_CLASS short xtcl_refnum ALLOC_INIT(-1); /* The reference number for application resource fork. */
ALLOC_CLASS short menu_modifiers ALLOC_INIT(0); /* Avoids repeating log file type setting */
ALLOC_CLASS short stuffit_available ALLOC_INIT(0); /* Avoids repeating log file type setting */
ALLOC_CLASS WindowPtr theFeedbackWindow ALLOC_INIT(NULL);
ALLOC_CLASS short feedback_showing ALLOC_INIT(false);
ALLOC_CLASS short pause_op ALLOC_INIT(false);
ALLOC_CLASS short yielding_on ALLOC_INIT(false);
ALLOC_CLASS short cursor_ibeam ALLOC_INIT(0);
ALLOC_CLASS short g_log_level ALLOC_INIT(0);
ALLOC_CLASS short engine_verbosity ALLOC_INIT(1); /* 0 - Quiet, 1 - Sound, 2 - Alert */
ALLOC_CLASS Rect scrnrect;
ALLOC_CLASS Rect dragrect;
ALLOC_CLASS Rect growrect;
ALLOC_CLASS MenuHandle mymenus ALLOC_ARRAY(MAX_MENU);
ALLOC_CLASS long gLastDown ALLOC_INIT(0);
ALLOC_CLASS EventRecord gEvent, gLastEvent;
ALLOC_CLASS RsrcData gRsrcData;
ALLOC_CLASS TEHandle gHTE ALLOC_INIT(NULL);
ALLOC_CLASS char gStr ALLOC_ARRAY(256); /* Global string to satisfy temporary needs. */
ALLOC_CLASS char temp_str ALLOC_ARRAY(256);
ALLOC_CLASS char input ALLOC_ARRAY(INPUT_SIZE);
ALLOC_CLASS unsigned char info_buffer ALLOC_ARRAY(256);
ALLOC_CLASS short has_wait_next_event ALLOC_INIT(0);
ALLOC_CLASS short in_back_ground ALLOC_INIT(0);
ALLOC_CLASS short g_log_wdref ALLOC_INIT(0);
ALLOC_CLASS char g_log_filename ALLOC_ARRAY(64) ALLOC_INIT("LOGFILE");
ALLOC_CLASS unsigned long g_next_cron_time ALLOC_INIT(0);
ALLOC_CLASS unsigned long g_cron_interval ALLOC_INIT(0);
ALLOC_CLASS short gHasAliases ALLOC_INIT(0);
ALLOC_CLASS short gHasBalloons ALLOC_INIT(0);
ALLOC_CLASS short gHasDirectory ALLOC_INIT(0);
ALLOC_CLASS short gHasAppleEvents ALLOC_INIT(0);
ALLOC_CLASS short gHasStandardFile ALLOC_INIT(0);
ALLOC_CLASS Tcl_Interp *g_interp ALLOC_INIT(0);
ALLOC_CLASS count_int *htab ALLOC_INIT((count_int *)0);
ALLOC_CLASS unsigned short *codetab ALLOC_INIT((unsigned short *)0);
ALLOC_CLASS THPrint gPrintRecord ALLOC_INIT(NULL);
ALLOC_CLASS TPrStatus gPrintStatus;
ALLOC_CLASS long def_text_file_creator ALLOC_INIT('MSWD');
ALLOC_CLASS TextConvSpec gTConv;
ALLOC_CLASS SysEnvRec theEnviron;
ALLOC_CLASS XPROCParmBlk g_cbpb;
ALLOC_CLASS Handle tge_sicns ALLOC_INIT(NULL);
ALLOC_CLASS Handle notify_icons ALLOC_ARRAY(NUM_OF_NOTIFY_ICONS);
ALLOC_CLASS int nm_polite_queued ALLOC_ARRAY(NUM_OF_NOTIFY_ICONS);
ALLOC_CLASS NMRec *nm_polite_ptr ALLOC_ARRAY(NUM_OF_NOTIFY_ICONS);
ALLOC_CLASS char kBuffer ALLOC_ARRAY(1024);
ALLOC_CLASS char *XTCLFileName ALLOC_INIT("\pXTCL File");
ALLOC_CLASS SearchReplaceParm search_replace_parms;
extern char *ctime();
extern char *time_stamp();
extern ListHandle setup_dlg_list();
extern int Cmd_DoMenuCmd();
extern int Cmd_DoCompress();
extern int Cmd_DoDeCompress();
extern int Cmd_DoAlertNote();
extern int Cmd_DoCD();
extern int Cmd_DoPWD();
extern int Cmd_GetDirectory();
extern int Cmd_CallExternalCMD();
extern int Cmd_DoGetenv();
extern int Cmd_DoPutenv();
extern int Cmd_AskYesNoCancel();
extern int Cmd_GetInputLine();
extern char *get_environment();
extern char *csavestr();
extern char *malloc();
extern Handle tcl_Houtput_gethdl();
extern pascal Boolean UniversalFilter();
extern Tcl_Interp *Tcl_CreateTickleInterp();
#ifdef MAKEDUMP
#ifdef TCLAPPL
# pragma dump ":obj:TickleHdrDump"
#else
# pragma dump ":obj:EngineHdrDump"
#endif
#endif
#endif /* ! USEDUMP */
#endif /* ! THINK_C_PRECOMPILED */